package com.wanxi.demo;

import com.wanxi.tool.Tool;

import java.util.Arrays;

public class JudgeSameArr {
    public static void main(String[] args) {
        /**
         * 思路：比较两个数组的内容是否相同
         * 1.直接比较长度？
         * 2.如果长度相同，则一个一个比较内容
         */
        int[] arrA = Tool.getIntArr(5);
        System.out.println(Arrays.toString(arrA));
        int[] arrB = Tool.getIntArr(5);
        System.out.println(Arrays.toString(arrB));
        boolean isSame = judge(arrA, arrA);
        System.out.println(isSame);
    }

    private static boolean judge(int[] arrA, int[] arrB) {
        if (arrA.length != arrB.length) {
            return false;
        }
        int length = arrA.length;
        for (int i = 0; i < length; i++) {
            if (arrA[i] != arrB[i]) {
                return false;
            }
        }
        return true;
    }
}
